inline openat2 syscall
authorMichael Tokarev <mjt@tls.msk.ru>
Wed, 21 Jan 2026 09:20:05 +0000 (12:20 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 24 Jan 2026 05:55:25 +0000 (08:55 +0300)
Forwarded: not-needed

openat2() is not provided by glibc, so is implemented in
samba's libreplace.  By inlining the implementation,
we avoid additional linkage to libreplace.

Not forwarding since proper fix needs proper clean-up
of the #ifdef'fery.

Gbp-Pq: Name inline-openat2.diff

lib/replace/system/filesys.h

index 9738ad52935cd232c714acddaf0f4c6c31ddb6fb..130ad4b55bdfe9c6dab2b94d6d017560ced57613 100644 (file)
@@ -272,10 +272,16 @@ struct __rep_open_how {
 #endif /* ! HAVE_LINUX_OPENAT2_H */
 
 #ifndef HAVE_OPENAT2
-long rep_openat2(int dirfd, const char *pathname,
-                struct open_how *how, size_t size);
-#define openat2(dirfd, pathname, how, size) \
-       rep_openat2(dirfd, pathname, how, size)
+#define HAVE_OPENAT2
+#ifdef __linux__
+#include <sys/syscall.h>
+static inline long openat2(int dirfd, const char *pathname,
+                          struct open_how *how, size_t size) {
+       return syscall(SYS_openat2, dirfd, pathname, how, size);
+}
+#else
+#define openat2(dirfd, path, how, size) (errno = -ENOSYS, -1)
+#endif
 #endif /* !HAVE_OPENAT2 */
 
 #ifdef DISABLE_OPATH